package com.example.runningdemo.designModel.factory.proxy;

/**
 * @program: Running-Demo
 * @description: 数据访问代理类，在不修改原有代码逻辑情况下，新增事务
 * @author: kangwei
 * @create: 2024-08-09 14:10
 **/
public class UserDaoProxy extends UserDao {

    private UserDao userDao;

    public UserDaoProxy(UserDao userDao) {
        this.userDao = userDao;
    }


    //    @Override
//    void save() {
//        System.out.println("开启事务");
//        super.save();
//        System.out.println("关闭事务");
//    }
    public void save() {
        System.out.println("开启事务");
        userDao.save();
        System.out.println("关闭事务");
    }

    public static void main(String[] args) {
       // new UserDaoProxy().save();
        UserDaoProxy userDaoProxy = new UserDaoProxy(new UserDao());
        userDaoProxy.save();
    }
}
